package ro.gateway.aida.charts;

import java.util.ArrayList;

import org.jfree.data.DefaultPieDataset;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: Jun 20, 2004
 * Time: 12:18:51 PM
 * To change this template use File | Settings | File Templates.
 */
public class PieChartDataMan {
	public static void populate_pie_dataset(
		  DefaultPieDataset pie_dataset, 
		  String language,
		  ChartWizzard$ActionForm form) {
		if (form.search_results == null) return;
		ArrayList distinct_rows = ChartUtils.getDistinctValues(form.search_results,
			  1, language,
			  form.x_axe_criteria.startsWith("year#"),
			  form); // serii

		for (int i = 0; i < distinct_rows.size(); i++) {
			Comparable row = (Comparable) distinct_rows.get(i);
			Number value = null;
			value = ChartUtils.compute_chart_value(row, null, form);
			pie_dataset.setValue(row != null ? row : "--", value);
		}
	}
	
}
